﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="../lib/html5.js"></script>
    <script type="text/javascript" src="../lib/respond.min.js"></script>
    <script type="text/javascript" src="../lib/PIE_IE678.js"></script>
    <![endif]-->
    <link href="../lib/layui/css/layui.css" rel="stylesheet" type="text/css" />
    <link href="../css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="../css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="../lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
    <link href="../lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="../lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>育苗管理</title>
</head>
<body>
    <div class="pt-5  pl-20 pr-20 pb-20">
        <form id="itemEdit" name="itemEdit" method="post" action="../ashx/spui.ashx" class="form form-horizontal">
            <input type="hidden" class="actionValue" id="editAction" name="action" value="add" />
            <input type="hidden" id="hcrainbackid" name="hcrainbackid" value="1" />
            <input type="hidden" id="id" name="id" />
            <input type="hidden" id="fgid" name="fgid" value="" />
            <input type="hidden" id="tablename" name="tablename" value="" />
            <input type="hidden" id="tablemidname" name="tablemidname" value="" />
            <input type="hidden" id="dataneedtouser" name="dataneedtouser" value="1" /><!--是否要包含通用数据必归属处理-->
            <input type="hidden" id="ftype" name="ftype" value="育苗任务" />
            <input type="hidden" id="ywcheckonly" name="ywcheckonly" value="ftaskno#当前生产编号已存在!" />
            <input type="hidden" id="ftaskbfmj" name="ftaskbfmj" value="0" /><!--报废面积-->

            <div id="tab-category" style="display: none;" class="HuiTab">
                <div class="tabBar cl" id="tab-categorybar"><span>任务主要信息</span><span>基本信息</span><span>移栽明细</span></div>
                <div class="tabCon" id="divtab1">
                </div>
                <div class="tabCon" id="divtab2">
                </div>
                <div class="tabCon" id="divtab3">
                </div>
            </div>
            <div class="cl" id="fold_category">
                <ul id="Huifold2" class="Huifold">
                    <li class="item">
                        <h4>生产任务<b>+</b></h4>
                        <div class="info" id="divfold1" style="display: block;">
                            <div id="divshow1">
                                <div class="row cl">
                                    <label class="form-label col-1">品种：</label>
                                    <div class="formControls col-2  layui-form">
                                        <select name="ftasksctype" id='ftasksctype' lay-filter="layseltasksctype" lay-verify="required" nullmsg="不能为空" datatype="*1-22" lay-search="">
                                            <option value="">直接选择或搜索选择</option>
                                        </select>
                                        <input type="hidden" id="ftasksctypename" name="ftasksctypename" value="" />
                                    </div>
                                    <div class="col-1"></div>

                                    <label class="form-label col-2">编号(自动)：</label>
                                    <div class="formControls col-3">
                                        <input type="text" class="input-text" name="ftaskno" id="ftaskno" placeholder="编号" value="" />
                                    </div>
                                    <div class="col-1"></div>
                                    <!--            <label class="form-label col-1">片区：</label>
                                    <div class="formControls col-2">
                                        <span class="select-box">
                                            <select class="select" size="1" name="fareaid" id="fareaid">
                                            </select>
                                        </span>
                                        <input type="hidden" id="fareaname" name="fareaname" value="" />
                                    </div>
                                    <div class="col-1"></div>-->
                                   
                                </div>
                                <div class="row cl">
                                    <label class="form-label col-1">地块信息：</label>
                                    <div class="formControls col-3">
                                        <input type="text" class="input-text" name="fmaindcinfo" id="fmaindcinfo" readonly="readonly" placeholder="右边选择或搜索选择" />
                                    </div>
                                    <div class="formControls col-8  layui-form">
                                        <select name="selectdcinfos" id='selectdcinfos' lay-filter="selectdcinfos" lay-search="true">
                                            <option value="">直接选择或搜索选择</option>
                                        </select>
                                        <input type="hidden" id="fareaid" name="fareaid" value="" />
                                        <input type="hidden" id="fareaname" name="fareaname" value="" />
                                        <input type="hidden" id="sondcid" name="sondcid" value="" />
                                        <input type="hidden" id="sondcname" name="sondcname" value="" />
                                        <input type="hidden" id="sondctype" name="sondctype" value="" />
                                        <input type="hidden" id="sondczjid" name="sondczjid" value="" />
                                        <input type="hidden" id="sondczjname" name="sondczjname" value="" />
                                        <input type="hidden" id="sondcuserid" name="sondcuserid" value="" />
                                        <input type="hidden" id="sondcusername" name="sondcusername" value="" />
                                        <input type="hidden" id="fmaindcid" name="fmaindcid" value="" />

                                    </div>
                                    <div class="col-1"></div>
                                </div>
                                <div class="row cl">
                                    <label class="form-label col-1">计划面积：</label>
                                    <div class="formControls col-2">
                                        <input type="text" class="input-text" name="ftaskmj" id="ftaskmj" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" placeholder="2~10个长度" />
                                    </div>
                                    <div class="col-1"></div>
                                    <label class="form-label col-1">播种时间：</label>
                                    <div class="formControls col-2">
                                        <input type="text" nullmsg="不能为空" datatype="*4-22" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" onchange="settaskno();" name="ftaskstarttime" id="ftaskstarttime" class="input-text Wdate" />
                                    </div>
                                    <div class="col-1"></div>
                                </div>
                                <div class="row cl" style="display: none;">
                                    <label class="form-label col-1">每次播种面积：</label>
                                    <div class="formControls col-2">
                                        <input type="text" class="input-text" name="fbjtimecount" id="fbjtimecount" nullmsg="不能为空" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" placeholder="2~10个长度" />
                                    </div>
                                    <div class="col-1"></div>
                                    <label class="form-label col-1">播种间隔（天）：</label>
                                    <div class="formControls col-2">
                                        <input type="text" class="input-text" name="fbjdaysplit" id="fbjdaysplit" nullmsg="不能为空" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" placeholder="2~10个长度" />
                                    </div>
                                    <div class="col-1"></div>
                                    <label class="form-label col-1">播种次数：</label>
                                    <div class="formControls col-2">
                                        <input type="text" class="input-text" name="fbjcount" id="fbjcount" nullmsg="不能为空" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" placeholder="2~10个长度" />
                                    </div>
                                    <div class="col-1"></div>
                                </div>
                                <div class="row cl">
                                    <label class="form-label col-1">状态：</label>
                                    <div class="formControls col-2">
                                        <span class="select-box">
                                            <select class="select" size="1" name="ftaskstatus" id="ftaskstatus">
                                                <option value="计划">计划</option>
                                                <option value="种植">种植</option>
                                                <option value="完成">完成</option>
                                                <option value="中止">中止</option>
                                            </select>
                                        </span>
                                    </div>
                                    <div class="col-1"></div>
                                    <label class="form-label col-1">采收时间：</label>
                                    <div class="formControls col-2">
                                        <input type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" name="ftaskendtime" id="ftaskendtime" class="input-text Wdate" />
                                    </div>
                                    <div class="col-1"></div>
                                    <label class="form-label col-1">采收估量：</label>
                                    <div class="formControls col-2 ">
                                        <input type="text" class="input-text" name="ftaskallget" id="ftaskallget" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" placeholder="2~10个长度" />
                                    </div>
                                </div>


                                <div class="row cl">
                                    <label class="form-label col-1">用工成本：</label>
                                    <div class="formControls col-2">
                                        <input type="text" class="input-text" name="ftaskugcb" id="ftaskugcb" placeholder="用工成本" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" />
                                    </div>
                                    <div class="col-1"></div>
                                    <label class="form-label col-1">任务说明：</label>
                                    <div class="formControls col-5">
                                        <input type="text" class="input-text" name="ftaskinfo" id="ftaskinfo" placeholder="任务说明" />
                                    </div>
                                    <div class="col-6">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </li>
                    <li class="item">
                        <h4>投入信息<b>+</b></h4>
                        <div class="info" id="divfold2" style="display: block;">
                            <div id="divshow2">
                                <div class="row cl">
                                    <label class="form-label col-1">选择种子：</label>
                                    <div class="col-5 layui-form">
                                        <select name="showfzbppcid1" id='showfzbppcid1' lay-filter="showfzbppcid1" lay-verify="required" lay-search="">
                                            <option value="">直接选择或搜索选择</option>
                                        </select>
                                    </div>
                                    <label class="form-label col-1">种子批号：</label>
                                    <div class="formControls col-5">
                                        <input type="text" class="input-text" name="fzzsourepc" id="fzzsourepc" placeholder="种子批号" />
                                    </div>
                                </div>
                                <div class="row cl">
                            

                                    <label class="form-label col-1">种子用量：</label>
                                    <div class="formControls col-2">
                                        <input type="text" class="input-text" name="fzzsoureccount" id="fzzsoureccount" placeholder="种子用量Kg" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" />
                                    </div>
                                    <div class="col-1"></div>
                                    <label class="form-label col-1">种子单价：</label>
                                    <div class="formControls col-2">
                                        <input type="text" class="input-text" name="fzzsoureprice" id="fzzsoureprice" placeholder="种子单价" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" />
                                    </div>
                                    <div class="col-1"></div>
                                    <!--种子的出库ID-->
                                    <input type="hidden" id="fzzsoureoutid" name="fzzsoureoutid" value="" />
                                    <!--种子的入库ID-->
                                    <input type="hidden" id="fzzsoureinid" name="fzzsoureinid" value="" />

                                </div>
                                <div class="row cl">
                                    <label class="form-label col-1">播种方式：</label>
                                    <div class="formControls col-2">
                                        <span class="select-box">
                                            <select class="select" name="fymway" id="fymway">
                                                <option value="机器播种">机器播种</option>
                                                <option value="人工点播">人工点播</option>
                                                <option value="撒播">撒播</option>
                                            </select>
                                        </span>
                                    </div>
                                    <div class="col-1"></div>
                                    <label class="form-label col-1">苗盘规格：</label>
                                    <div class="formControls col-2">
                                        <input type="text" class="input-text" name="fymgg" id="fymgg" placeholder="育苗盘规格" />
                                    </div>
                                    <div class="col-1"></div>
                                    <label class="form-label col-1">育苗盘数：</label>
                                    <div class="formControls col-2">
                                        <input type="text" class="input-text" name="fymsl" id="fymsl" placeholder="育苗盘数" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" />
                                    </div>
                                </div>
                                <div class="row cl">
                                    <label class="form-label col-1">种子处理：</label>
                                    <div class="formControls col-2">
                                        <span class="select-box">
                                            <select class="select" size="1" name="fzjclfs" id="fzjclfs"></select>
                                        </span>
                                    </div>
                                    <div class="col-1"></div>
                                    <label class="form-label col-1">基质数量：</label>
                                    <div class="formControls col-2">
                                        <input type="text" class="input-text" name="fymuseringjjcount" id="fymuseringjjcount" placeholder="育苗基质数量" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" />
                                    </div>
                                    <div class="col-1"></div>
                                    <label class="form-label col-1">基质成本：</label>
                                    <div class="formControls col-2">
                                        <input type="text" class="input-text" name="fymuseringjjprice" id="ymuseringjjprice" placeholder="育苗基质成本" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" />
                                    </div>
                                </div>
                                <div class="row cl">
                                    <label class="form-label col-1">已移数：</label>
                                    <div class="formControls col-2">
                                        <input type="text" class="input-text" name="fymhasmovecount" id="fymhasmovecount" placeholder="已移数" value="0" />
                                    </div>
                                </div>

                                <!--<div class="row cl">
                                    <label class="form-label col-1">育苗记录：</label>
                                    <div class="col-5 layui-form">
                                        <select name="selectymchangetask" id='selectymchangetask' lay-filter="selectymchangetask" lay-search="">
                                            <option value="">直接选择或搜索选择</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="row cl">
                                    <label class="form-label col-1">移栽盘数：</label>
                                    <div class="formControls col-2">
                                        <input type="text" class="input-text" name="fymchangetaskcount" id="fymchangetaskcount" placeholder="移栽盘数" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" />
                                    </div>
                                    <div class="col-1"></div>
                                    <label class="form-label col-1">盘规格：</label>
                                    <div class="formControls col-2">
                                        <div class="col-1"></div>
                                        <input type="text" class="input-text" name="fymchangetaskgg" id="fymchangetaskgg" placeholder="移栽的盘规格" />
                                    </div>
                                    <label class="form-label col-1">一盘成本：</label>
                                    <div class="formControls col-2">
                                        <div class="col-1"></div>
                                        <input type="text" class="input-text" name="fymchangetaskcb" id="fymchangetaskcb" placeholder="一盘成本" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" />
                                    </div>
                                </div>
                                <div class="row cl">
                                    <label class="form-label col-1">育苗批次：</label>
                                    <div class="formControls col-2">
                                        <input type="text" class="input-text" name="fymchangetaskno" id="fymchangetaskno" placeholder="育苗批次号" />
                                    </div>
                                    <div class="col-1"></div>
                                </div>-->

                            </div>
                        </div>
                    </li>
                    <li class="item">
                        <h4>移栽明细<b>+</b></h4>
                        <div class="info" id="divfold3" style="display: block;">
                            <div id="divshow3">
                                <div class="panel panel-default    mt-20">
                                    <!--                            <div class="panel-header"><a href="javascript:;" onclick="addTaskDcInfo()" class="btn btn-danger  round"><i class="Hui-iconfont">&#xe600;</i>添加要用的地块</a></div>-->
                                    <div>
                                        <table class="table table-border table-bordered table-striped table-hover" id="tablelist" width="100%">
                                            <thead>
                                                <tr class="text-c">
                                                    <th width="30"><a id="hcmtable_sall" onclick="hcmtable_sall();" href="javascript:;" title="全选反选"><i class="Hui-iconfont">&#xe608;全</i></a></th>
                                                    <th>地块编号</th>
                                                    <th>所用数量</th>
                                                    <th>说明</th>
                                                    <th>操作</th>
                                                </tr>
                                            </thead>
                                            <tbody></tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
            <div class="row cl">
                <div class="col-6 col-offset-4">
                    <button onclick="changeshowtype();" class="btn btn-danger radius" type="button">切换显示</button>&nbsp;&nbsp;&nbsp;&nbsp;
                    <button class="btn btn-primary radius" type="submit" id="btsub1">提交</button>&nbsp;&nbsp;
                    <button class="btn btn-secondary radius" type="button" id="btn_reset">重置</button>&nbsp;&nbsp;
                    <!--  <button onclick="printPDF();" class="btn btn-default radius" type="button">打印</button>-->
                    <button onclick="layer_close();" class="btn btn-default radius" type="button">返回</button>
                </div>
            </div>
            <div class="row cl">
                <div class="col-10" id="divforhcrfbutton">
                </div>
            </div>
        </form>
    </div>
    <iframe style="display: none" id="printIframe"></iframe>
    <script src="../hcjsui/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../lib/layui/layui.js"></script>
    <script type="text/javascript" src="../lib/icheck/jquery.icheck.min.js"></script>
    <script type="text/javascript" src="../lib/Validform/5.3.2/Validform.js"></script>
    <script type="text/javascript" src="../lib/layer/1.9.3/layer.js"></script>
    <script src="../hcjsui/js/_Define.js" type="text/javascript"></script>
    <script type="text/javascript" src="../js/hcui.js"></script>
    <script type="text/javascript" src="../js/hcui_au.js"></script>
    <script type="text/javascript" src="../lib/My97DatePicker/WdatePicker.js"></script>

    <script type="text/javascript" src="../lib/datatables/1.10.0/jtable.js"></script>
    <script type="text/javascript" src="../js/hcui_list.js"></script>

    <script type="text/javascript">
        //当前地块信息
        var inoutusernameselObj = [];
        var Mfv7 = "";
        var Mdc = "";
        //Mhcloadback[0] = "ftasksctype";
        HcUiAuloadInfoAuto = false;//将自动加载，设置为false（禁用自动加载）
        spsetBaseNoBt("hsc_task", "id", "hsc_task as T", "*", "#tablelist", "hsc_task", "生产任务管理", "sctasklist-ae");
        hcui_ajaxasync = false;
        var jjm = [];
        //种植物
        hcdoselbyPost("id,fv1 as name,fv7", "yw_baseinfo", "type=1 and maintype=1", "", "", "id",
               function (data) {
                   jjm = data;
                   SetSelectWithArrayIdName("#ftasksctype", data);
                   if (uiform) uiform.render('');//这个好像不用再保留了
               });
        var uiform = null;
        var selectstoreinfo = [];
        var selectstoreoutinfo = [];
        var urlinfoid = "";
        var urlinfomj = "";
        var fplantjpstoreinfo = [];
        //加载处理
        function loadin() {
            $("#ftaskstarttime").val((new Date()).Format("yyyy-MM-dd"));//开始时间
            $("#ftaskendtime").val((addDate(new Date(), 24 * 15)).Format("yyyy-MM-dd"));//结束时间

            $('#ftaskmj').val(getUrlParam("urlinfomj"));
            //加载种子的库存信息
            hcdoselbyPost("id,concat(spname,'批次:',spbasepc,'-厂家:',spbasecj,'-库存:',count-hasout,'-日期:',case when spbasecdate  is null  then '' else   DATE_FORMAT(spbasecdate,'%Y-%m-%d') END  ) as name,spbasepc,spbasecj,spbasecdate,unit,price,spbasezj,count-hasout as count, spname,spid,spbasedesc,spmaintype", "herp_inoutorderlist", "databranchid='" + HCUser.HCUorg + "'   and datastate='入库' and spmaintype='种子' and count-hasout>0", "", "", "dataaddtime asc", function (datab) {
                SetSelectWithArrayIdName("#showfzbppcid1", datab);
                fplantjpstoreinfo = datab;

            });

            urlinfoid = getUrlParam("urlinfoid");
            //加载种子处理方式-字典
            hcdoselbyPost("dictdata_code id,dictdata_name as name", "dictionarydata", "dict_code='SeedTreatment'", "", "", "orderindex",
                 function (data) {
                     SetSelectWithArrayIdName("#fzjclfs", data);
                 });


            //加载区域
            hcdoselbyPost("id,fv1 as name", "yw_baseinfo", "type='5' and  maintype='5' and databranchid=" + HCUser.HCUorg, "", "", "id",
                   function (data) {
                       SetSelectWithArrayIdName("#fareaid", data);
                   });
            //地块信息
            hcdoselbyPost("id,concat(fv4,'-',fv1,'-',fv8,'-',fv9,'-',fv6) as name,nv1,fv1,fv8,fv10,fv7,fv9,fv6,fv4,fv5", "yw_baseinfo", "type=2 and maintype=2 and databranchid=" + HCUser.HCUorg, "", "", "id",
                   function (data) {
                       SetSelectWithArrayIdName("#selectdcinfos", data);
                       inoutusernameselObj = data;
                       if (uiform) uiform.render('select');
                       //加载默认的地块信息
                       {
                           $('#sondcid').val(urlinfoid);
                           $('#fareaid').val(hcgetJsonObjById(inoutusernameselObj, urlinfoid).fv5);
                           $('#fareaname').val(hcgetJsonObjById(inoutusernameselObj, urlinfoid).fv4);
                           $('#sondcname').val(hcgetJsonObjById(inoutusernameselObj, urlinfoid).fv1);
                           $('#sondctype').val(hcgetJsonObjById(inoutusernameselObj, urlinfoid).fv8);
                           $('#sondczjid').val(hcgetJsonObjById(inoutusernameselObj, urlinfoid).fv10);
                           $('#sondczjname').val(hcgetJsonObjById(inoutusernameselObj, urlinfoid).fv9);
                           $('#sondcuserid').val(hcgetJsonObjById(inoutusernameselObj, urlinfoid).fv7);
                           $('#sondcusername').val(hcgetJsonObjById(inoutusernameselObj, urlinfoid).fv6);
                           $('#fmaindcinfo').val(hcgetJsonObjById(inoutusernameselObj, urlinfoid).name);
                           $('#fmaindcid').val(urlinfoid);
                       }
                   });
            layui.use(['form'], function () {
                uiform = layui.form();

                //因为这个慢，所在加载要从这个开始
                loadInfoById(aumid, function (data) {
                    loadback(data);
                });
                uiform.on('select(layseltasksctype)', function (data) {
                    Mfv7 = hcgetJsonObjById(jjm, data.value).fv7;
                    $('#ftasksctypename').val($("#ftasksctype").find("option:selected").text());
                    settaskno();
                    ////加载库存信息
                    //hcdoselbyPost("id,concat('批次:',spbasepc,'-厂家:',spbasecj,'-单价：',price,'-库存：',count-hasout,'-生产日期:',case when spbasecdate  is null  then '' else  spbasecdate END  ) as name,spbasepc,spbasecj,spbasepc,spbasecdate,unit,price,spbasezj,count-hasout as countnew,fromid", "herp_inoutorderlist", "databranchid='" + HCUser.HCUorg + "' and spname  like '%" + $('#ftasksctypename').val() + "%' and datastate='入库'  and count-hasout>0", "", "", "dataaddtime asc", function (data) {
                    //    SetSelectWithArrayIdName("#selectstorelog", data);
                    //    selectstoreinfo = data;
                    //    if (uiform) uiform.render('select');
                    //});
                });
                uiform.on('select(selectdcinfos)', function (data) {
                   
                    $('#sondcid').val(data.value);
                    $('#fareaid').val(hcgetJsonObjById(inoutusernameselObj, data.value).fv5);
                    $('#fareaname').val(hcgetJsonObjById(inoutusernameselObj, data.value).fv4);
                    $('#sondcname').val(hcgetJsonObjById(inoutusernameselObj, data.value).fv1);
                    $('#sondctype').val(hcgetJsonObjById(inoutusernameselObj, data.value).fv8);
                    $('#sondczjid').val(hcgetJsonObjById(inoutusernameselObj, data.value).fv10);
                    $('#sondczjname').val(hcgetJsonObjById(inoutusernameselObj, data.value).fv9);
                    $('#sondcuserid').val(hcgetJsonObjById(inoutusernameselObj, data.value).fv7);
                    $('#sondcusername').val(hcgetJsonObjById(inoutusernameselObj, data.value).fv6);
                    $('#fmaindcinfo').val($("#selectdcinfos").find("option:selected").text());
                    $('#fmaindcid').val(data.value);
                    Mdc = hcgetJsonObjById(inoutusernameselObj, data.value).fv1;
                    settaskno();
                    // $('#ftasksctypename').val($("#ftasksctype").find("option:selected").text());
                });
                //种子出库的选择
                uiform.on('select(showfzbppcid1)', function (data) {
                    $('#fzzsourepc').val(hcgetJsonObjById(fplantjpstoreinfo, data.value).name);
                    $('#fzzsoureprice').val(hcgetJsonObjById(fplantjpstoreinfo, data.value).price);
                    $('#fzzunit').val(hcgetJsonObjById(fplantjpstoreinfo, data.value).unit);
                    $('#fzzsoureinid').val(hcgetJsonObjById(fplantjpstoreinfo, data.value).id);//入库
   
                });

                ////种子出库的选择
                //uiform.on('select(selectoutlog)', function (data) {
                //    $('#fzzsourepc').val(hcgetJsonObjById(selectstoreoutinfo, data.value).spbasepc);
                //    $('#fzzsoureccount').val(hcgetJsonObjById(selectstoreoutinfo, data.value).count);
                //    $('#fzzsoureprice').val(hcgetJsonObjById(selectstoreoutinfo, data.value).price);
                //    $('#fzzsoureoutid').val(data.value);
                //    $('#fzzsoureinid').val(hcgetJsonObjById(selectstoreoutinfo, data.value).fromid);
                //});
                ////种子库存的选择
                //uiform.on('select(selectstorelog)', function (data) {
                //    $('#fzzsourepc').val(hcgetJsonObjById(selectstoreinfo, data.value).spbasepc);
                //    $('#fzzsoureccount').val(hcgetJsonObjById(selectstoreinfo, data.value).countnew);
                //    $('#fzzsoureprice').val(hcgetJsonObjById(selectstoreinfo, data.value).price);
                //    $('#fzzsoureoutid').val(data.value);
                //    $('#fzzsoureinid').val(hcgetJsonObjById(selectstoreinfo, data.value).fromid);
                //});

            });

            if (getUrlParam("action") == "add") {
                $("#fgid").val(NewGuid());
                settaskno();

            }
            $.Huitab("#tab-category .tabBar span", "#tab-category .tabCon", "current", "click", "0");
            $.Huifold("#Huifold2 .item h4", "#Huifold2 .item .info", "", 3, "click");
        }

        function loadback(data) {
            uiform.render();//这个不能去掉,坑啊
            //加载出库信息
            //if (aumid) hcdoselbyPost("id,concat('批次:',spbasepc,'-厂家:',spbasecj,'-单价：',price,'-出库：',count,'-生产日期:',case when spbasecdate  is null  then '' else  spbasecdate END  ) as name,spbasepc,spbasecj,spbasepc,spbasecdate,unit,price,spbasezj,count-hasout as countnew,fromid,count", "herp_inoutorderlist", "databranchid='" + HCUser.HCUorg + "'  and totaskid=" + aumid + " and datastate='出库' ", "", "", "dataaddtime asc", function (data) {
            //    SetSelectWithArrayIdName("#selectoutlog", data);
            //    selectstoreoutinfo = data;
            //    if (uiform) uiform.render('select');
            //});
            //加载库存信息
            //if ($('#ftasksctypename').val()) hcdoselbyPost("id,concat('批次:',spbasepc,'-厂家:',spbasecj,'-单价：',price,'-库存：',count-hasout,'-生产日期:',case when spbasecdate  is null  then '' else  spbasecdate END  ) as name,spbasepc,spbasecj,spbasepc,spbasecdate,unit,price,spbasezj,count-hasout as countnew,fromid", "herp_inoutorderlist", "databranchid='" + HCUser.HCUorg + "' and spname  like '%" + $('#ftasksctypename').val() + "%' and datastate='入库'  and count-hasout>0", "", "", "dataaddtime asc", function (data) {
            //    SetSelectWithArrayIdName("#selectstorelog", data);
            //    selectstoreinfo = data;
            //    if (uiform) uiform.render('select');
            //});
            //列表信息加载
            if (aumid) {
                hcmtable = $("#tablelist").DataTable({
                    "serverSide": true,
                    "bFilter": false,
                    "bLengthChange": false,
                    "ajax": {
                        "type": "POST",
                        "url": sposelUrl("hsc_task", "*", " and ymid=" + aumid) + "&sporderby=id",
                        "data": function (d) {
                        }
                    },
                    aLengthMenu: [100],
                    "columns": [
                         { "data": "rowhcindex" }
    , { "data": "maindcinfo" }
    , { "data": "ymchangetaskcount" }
   , { "data": "taskno" }
    , { "data": "id" }
                    ],
                    "columnDefs": [
                        {
                            "targets": [4],
                            "render": function (data, type, row) {
                                return "";
                                //"<a style=\"text-decoration:none\" class=\"ml-5\" onclick=\"toolUpdateById('" + data + "','','')\" href=\"javascript:;\" title=\"编辑\"><i class=\"Hui-iconfont\">&#xe6df;编辑</i></a> " +
                                //"<a style=\"text-decoration:none\" class=\"ml-5\" onclick=\"toolDelete('" + data + "','hsc_task_info','id')\"     href=\"javascript:;\" title=\"删除\"><i class=\"Hui-iconfont\">&#xe6e2;删除</i></a>";
                            }
                        },

                    {
                        "orderable": false,
                        "targets": [0, 1, 2, 3]
                    }
                    ]
                });
            }
        }

        function addTaskDcInfo() {
            if (aumid != "" && aumid != null && aumid != 'undefined') {
                toolAdd("添加所用地块信息", "sctasklist-ae-ae.html?action=add&maintype=" + aumid, 850, 400);
            }
            else {
                layer.alert("请在编辑情况下操作", { icon: 1 });
            }
        }
    </script>
    <script type="text/javascript">

        //提交数据后,回调
        function subback(data) {

            if (auhcotype == "add" && data.status == "y") {
                var addinfo = "taskid%" + data.info
               + "$infotypename%生产关联地块$infotype%1$infobytype1%1"
               + "$infoid%" + $("#sondcid").val()
               + "$infofv1%" + $("#sondcname").val()
               + "$infonv1%" + $("#ftaskmj").val()
               + "$infofv3%" + $("#sondctype").val()
                + "$infofv4%" + $("#sondczjid").val()
                + "$infofv5%" + $("#sondczjname").val()
                + "$infofv6%" + $("#sondcuserid").val()
                + "$infofv7%" + $("#sondcusername").val();
                hcdoadd201702("hsc_task_info", addinfo, 1, "{'settype':1,'byfile_name':'taskid'}", "", function (info) {
              
                    if (info == "ok") {


                        //同步库存信息  投入品种子使用
                        if ($("#fzzsoureinid").val() != "" && $("#fzzsoureinid").val() > 0 && $("#fzzsoureccount").val() > 0) {

                            var typ1id = $("#fzzsoureinid").val();
                            var thistypinfo = hcgetJsonObjById(fplantjpstoreinfo, typ1id);
                            var addinfo = "gid%" + NewGuid()
                           + "$ordergid%" + $("#fgid").val()
                           + "$spmaintype%" + thistypinfo.spmaintype
                           + "$spid%" + thistypinfo.spid
                           + "$spname%" + thistypinfo.spname
                           + "$count%" + $("#fzzsoureccount").val()
                           + "$price%" + thistypinfo.price
                            + "$spbasecj%" + thistypinfo.spbasecj
                           + "$spbasezj%" + thistypinfo.spbasezj
                           + "$spbasepc%" + thistypinfo.spbasepc
                           + "$spbasecdate%" + thistypinfo.spbasecdate
                           + "$fromid%" + typ1id//这里为库存ID
                           + "$totaskid%" + data.info//这里为任务ID
                           + "$totaskinfo%" + $("#ftaskno").val()//这里用任务NO
                           + "$spbasedesc%" + thistypinfo.spbasedesc
                           + "$hasout%0" + "$state%育苗直接出库" + "$datastate%出库"
                           + "$unit%" + thistypinfo.unit;
                            hcdoadd201702("herp_inoutorderlist", addinfo, 1, "", "", function (info) {
                                if (info == "ok") {
                                    //更新入库
                                    hcdoedit("herp_inoutorderlist", "id", typ1id, "hasout%hcrainself(hasout+" + $('#fzzsoureccount').val() + ")", function (info2) {
                                    });
                                }
                            });
                        }



                        layer.confirm('添加成功!', {
                            btn: ['继续添加', '返回'] //按钮
                        }, function (index) {
                            $("#fgid").val(NewGuid());

                            settaskno();
                            layer.msg('请输入下一个任务信息', { icon: 1 });
                        }, function (index) {
                            layer_close();

                        }
                    );
                    } else {
                        layer.msg(info, { icon: 2 });
                    }
                });
            }
            else {
                if (data.status == "y") {
                    if ($("#sondcid").val() != "") {
                        var addinfo = "taskid%" + $("#id").val()
                  + "$infotypename%生产关联地块$infotype%1$infobytype1%1"
                  + "$infoid%" + $("#sondcid").val()
                  + "$infofv1%" + $("#sondcname").val()
                  + "$infonv1%" + $("#ftaskmj").val()
                  + "$infofv3%" + $("#sondctype").val()
                   + "$infofv4%" + $("#sondczjid").val()
                   + "$infofv5%" + $("#sondczjname").val()
                   + "$infofv6%" + $("#sondcuserid").val()
                   + "$infofv7%" + $("#sondcusername").val();
                        hcdoadd201702("hsc_task_info", addinfo, 1, "{'settype':1,'byfile_name':'taskid'}", "", function (info) {
                            if (info == "ok") {
                                layer.msg("保存成功", { icon: 1 });
                            }
                            else {
                                layer.msg(info, { icon: 2 });
                            }
                        });
                    } else {
                        hcdoedit("hsc_task_info", "taskid", $("#id").val(), "infonv1%" + $("#ftaskmj").val(), function (info) {
                            layer.msg(info, { icon: 1 });
                        });
                    }
                }
                else {
                    layer.alert(data.info, { icon: 2 });
                }
            }
        }

        var divshowtype = 2;
        //切换事件
        function changeshowtype() {
            if (divshowtype == 1) {
                $("#divshow1").appendTo("#divfold1");
                $("#divshow2").appendTo("#divfold2");
                $("#divshow3").appendTo("#divfold3");
                $("#fold_category").show();
                $("#tab-category").hide();
                divshowtype = 2;
            }
            else {
                $("#divshow1").appendTo("#divtab1");
                $("#divshow2").appendTo("#divtab2");
                $("#divshow3").appendTo("#divtab3");
                $("#fold_category").hide();
                $("#tab-category").show();
                divshowtype = 1;
            }
        }
        //重写  提交前数据处理
        function hcrBeforeSub() {
            //$("#fareaname").val($('#fareaid option:selected').text());
            if (auhcotype == "add" && $("#sondcid").val() == "") {
                layer.msg("请选择地块信息", { icon: 2 });
                return false;
            }

        }
        // 日期，在原有日期基础上，增加days小时，默认增加1
        function addDate(date, days) {
            if (days == undefined || days == '') {
                days = 1;
            }
            var date = new Date(date);
            date.setHours(date.getHours() + days);
            return date;
            //var month = date.getMonth() + 1;
            //var day = date.getDate();
            //return date.getFullYear() + '-' + getFormatDate(month) + '-' + getFormatDate(day);
        }
        function settaskno() {
            //if ($("#ftaskstarttime").val().length > 1) {
            //    var datenow = new Date();

            //    var date = new Date($("#ftaskstarttime").val());
            //    date.setHours(datenow.getHours());
            //    date.setMinutes(datenow.getMinutes());
            //    date.setSeconds(datenow.getSeconds());
            //    $("#ftaskno").val(HCUser.HCUorgCode + "P" + (date).Format("yyyyMMddhhmmss"));
            //}
            //else
            //    $("#ftaskno").val(HCUser.HCUorgCode + "P" + (new Date()).Format("yyyyMMddhhmmss"));
            var dc = Mdc;
            var day = "";
            var jjm = Mfv7;
            if ($("#ftaskstarttime").val().length > 1) {
                var datenow = new Date();

                var date = new Date($("#ftaskstarttime").val());
                date.setHours(datenow.getHours());
                date.setMinutes(datenow.getMinutes());
                date.setSeconds(datenow.getSeconds());
                day = (date).Format("yyyyMMdd");
                //$("#ftaskno").val(HCUser.HCUorgCode + (date).Format("yyyyMMddhhmmss"));
            }
            else {
                day = (new Date()).Format("yyyyMMdd")
            }
            $("#ftaskno").val(HCUser.HCUorgCode + "PY" + dc + day + jjm);


        }
    </script>
</body>
</html>
